//
//  SIXFriendTableController.m
//  weibo
//
//  Created by   李小云 on 16/5/21.
//  Copyright © 2016年 chuhan. All rights reserved.
//

#import "SIXFriendTableController.h"
#import "UIImage+GIF.h"

@interface SIXFriendTableController ()<UITableViewDataSource,UITableViewDelegate,UIActionSheetDelegate>
/**
 *  tableview属性
 */
@property(nonatomic,strong)UITableViewController *tableViewControll;
@end

@implementation SIXFriendTableController

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置导航条内容
    self.navigationItem.title = @"添加好友";
    self.navigationController.navigationBar.tintColor = [UIColor grayColor];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"navigationbar_more"] style:UIBarButtonItemStylePlain target:self action:@selector(rigthBtn)];
  //创建tableView,并设置位置和尺寸,代理和数据源
    UITableViewController *tableViewControll = [[UITableViewController alloc]init];
    tableViewControll.tableView.dataSource = self;
    tableViewControll.tableView.delegate = self;
    tableViewControll.view.frame = CGRectMake(0, 0, self.view.frame.size.width, 400);
    _tableViewControll =tableViewControll;
    tableViewControll.tableView.rowHeight = 60;
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:tableViewControll.tableView];
    [self addChildViewController:tableViewControll];

}
-(void)rigthBtn{
    
    UIActionSheet *sheet = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"刷新",@"返回首页", nil];
    
    [sheet showInView:self.view];
    
}
/**
 *  actionSheet代理 需要跳转到首页 未实行
 *
 */
#pragma mark -actionSheet代理方法
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    if (buttonIndex == 1) {
        
    }
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return 3;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    

    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];
    
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    if (indexPath.row == 0) {
        cell.textLabel.text = @"当面加好友";
        cell.contentView.tag = 0;
        cell.detailTextLabel.text = @"添加身边的好友";
        cell.imageView.image = [UIImage imageNamed:@"addDanMian"];
    }
    
    if (indexPath.row == 1) {
        cell.textLabel.text = @"扫一扫";
        cell.contentView.tag = 1;
        cell.detailTextLabel.text = @"扫描二维码名片";
        cell.imageView.image = [UIImage imageNamed:@"saoYiSao"];
    }
    
    if (indexPath.row == 2) {
        cell.textLabel.text = @"通讯录好友";
        cell.detailTextLabel.text = @"添加或要求通讯录中的好友";
        cell.imageView.image = [UIImage imageNamed:@"tongXunLuHaoYou"];
    }
    return cell;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *view = [[[NSBundle mainBundle]loadNibNamed:@"fieldView" owner:nil options:nil]lastObject];
    for (UITextField *field in view.subviews) {
        
        if ([field isKindOfClass:[UITextField class]]) {
            
            field.placeholder = @"搜索昵称";
        }
    }
    return view;
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    return 40;
}

#pragma mark - cell 点击事件
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    /**
     *  添加二维码扫描事件
     */
    if (cell.contentView.tag == 1) {
        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"SIXScaneNavController" bundle:nil];
        UINavigationController *vc = [storyBoard instantiateInitialViewController];
        
        [self presentViewController:vc animated:YES completion:nil];
        
    }
    /**
     *  添加雷达Gif效果图
     */
    if (cell.contentView.tag == 0) {
        
        UIViewController *vc = [[UIViewController alloc]init];
        UIImageView *image1 = [[UIImageView alloc]init];
        image1.frame = self.view.frame;
        image1.image = [UIImage sd_animatedGIFNamed:@"123"];
        image1.userInteractionEnabled = YES;
        [vc.view addSubview:image1];
        
        UIImageView *centImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"68"]];
        
        centImage.layer.masksToBounds = YES;
        centImage.layer.cornerRadius = 50;
        centImage.bounds = CGRectMake(0, 0, 100, 100);
        centImage.center = self.view.center;

        [image1 addSubview:centImage];
        UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [backBtn setTitle:@"关闭" forState:UIControlStateNormal];
        [backBtn sizeToFit];
        backBtn.frame = CGRectMake(50, 50, 40, 40);
        [backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
        [image1 addSubview:backBtn];
        [self presentViewController:vc animated:YES completion:nil];
                       }
    
}
/**
 *  雷达界面按钮点击事件
 */
-(void)back{
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}
@end
